﻿using System.Collections.Generic;
using OBoobsWallpaper.Entity;

namespace OBoobsWallpaper.Logic
{
    public interface IRssManager
    {
        void Refresh();
    }

    public class RssManager : IRssManager
    {
        private readonly IRssCache rssCache;
        private readonly IRssLoader rssLoader;

        public RssManager(IRssCache rssCache, IRssLoader rssLoader)
        {
            this.rssCache = rssCache;
            this.rssLoader = rssLoader;
        }

        public void Refresh()
        {
            var loadRss = rssLoader.LoadRss();
            rssCache.Push(loadRss.RssItems);
        }

        public List<RssItem> GetTop()
        {
            return rssCache.GetLastElements();
        }
    }
}
